"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _hooks = require("../../hooks");

var _utils = require("../../utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Title = function Title(_ref) {
  var labelClass = _ref.labelClass,
      labelStyle = _ref.labelStyle,
      schema = _ref.schema,
      displayType = _ref.displayType;

  var _useStore = (0, _hooks.useStore2)(),
      globalDisplayType = _useStore.displayType,
      readOnly = _useStore.readOnly;

  var title = schema.title,
      description = schema.description,
      required = schema.required,
      type = schema.type;
  var isObjType = type === 'object';

  var _displayType = schema.displayType || displayType || globalDisplayType || 'column';

  return /*#__PURE__*/_react.default.createElement("div", {
    className: labelClass,
    style: labelStyle
  }, title ? /*#__PURE__*/_react.default.createElement("label", {
    className: "fr-label-title ".concat((0, _utils.isCheckBoxType)(schema, readOnly) || _displayType === 'column' ? 'no-colon' : '') // checkbox不带冒号
    ,
    title: title
  }, required === true && /*#__PURE__*/_react.default.createElement("span", {
    className: "fr-label-required"
  }, " *"), /*#__PURE__*/_react.default.createElement("span", {
    className: "".concat(isObjType ? 'b' : '', " ").concat(_displayType === 'column' ? 'flex-none' : '')
  }, /*#__PURE__*/_react.default.createElement("span", {
    dangerouslySetInnerHTML: {
      __html: title
    }
  })), description && (_displayType === 'row' ? /*#__PURE__*/_react.default.createElement("span", {
    className: "fr-tooltip-toggle",
    "aria-label": description
  }, /*#__PURE__*/_react.default.createElement("i", {
    className: "fr-tooltip-icon"
  }), /*#__PURE__*/_react.default.createElement("div", {
    className: "fr-tooltip-container"
  }, /*#__PURE__*/_react.default.createElement("i", {
    className: "fr-tooltip-triangle"
  }), description)) : _displayType === 'inline' ? null : /*#__PURE__*/_react.default.createElement("span", {
    className: "fr-desc ml2"
  }, "(\xA0", description, "\xA0)"))) : null);
};

var _default = Title;
exports.default = _default;